package com.yao.mssm.generator;


import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.rules.DbType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;


public class MssmGeneratorConfig extends AbstractGeneratorConfig{

	@Override
    protected void globalConfig() {
        super.globalConfig.setOutputDir("E:/workspace/mssm/src/main/java");
        super.globalConfig.setFileOverride(true);
        super.globalConfig.setEnableCache(false);
        super.globalConfig.setBaseResultMap(true);
        super.globalConfig.setBaseColumnList(true);
        super.globalConfig.setAuthor("yao");
        // 自定义文件命名，注意 %s 会自动填充表实体属性！
        super.globalConfig.setMapperName("%sDao");
    }

    @Override
    protected void dataSourceConfig() {
        super.dataSourceConfig.setDbType(DbType.MYSQL);
        super.dataSourceConfig.setDriverName("com.mysql.jdbc.Driver");
        super.dataSourceConfig.setUsername("root");
        super.dataSourceConfig.setPassword("123456");
        super.dataSourceConfig.setUrl("jdbc:mysql://127.0.0.1:3306/mssm?characterEncoding=utf8");
    }

    @Override
    protected void strategyConfig() {
        //strategy.setTablePrefix(new String[]{"_"});// 此处可以修改为您的表前缀
        super.strategyConfig.setInclude(new String[]{"menu"});
        super.strategyConfig.setNaming(NamingStrategy.underline_to_camel);// 表名生成策略
        // 自定义实体父类
        super.strategyConfig.setSuperEntityClass("com.baomidou.mybatisplus.activerecord.Model");
        // 自定义 mapper 父类
        super.strategyConfig.setSuperMapperClass("com.baomidou.mybatisplus.mapper.BaseMapper");
     	// 自定义 service 父类
        super.strategyConfig.setSuperServiceClass("com.baomidou.mybatisplus.service.IService");
     	 // 自定义 service 实现类父类
        super.strategyConfig.setSuperServiceImplClass("com.yao.mssm.system.service.support.BaseServiceImpl");
        super.strategyConfig.setSuperControllerClass("com.yao.mssm.base.controller.BaseController");
        
    }

    @Override
    protected void packageConfig() {
        super.packageConfig.setParent("com.yao.mssm");
        super.packageConfig.setModuleName("system");
        super.packageConfig.setEntity("entity");
        super.packageConfig.setMapper("dao");
        super.packageConfig.setXml("dao.mapper");
        super.packageConfig.setService("service");      
        super.packageConfig.setServiceImpl("service.impl");  
        super.packageConfig.setController("controller"); 
    }

    public static void main(String[] args) {
        AutoGenerator generator = new MssmGeneratorConfig().getGenerator();
        generator.execute();
    }

}
